home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 25
/
Cream of the Crop 25.iso
/
program
/
ny_src.zip
/
AEDIT.CPP
next >
Wrap
C/C++ Source or Header
|
1995-03-16
|
2KB
|
106 lines
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define LEVELS 21
void dump(void);
typedef enum {HANDS,PEPPER,KNIFE,CHAIN,GUN,RIFLE,LASER_GUN,SHOTGUN,MACHINEGUN,GRANADE_LAUNCHER,BLASTER,A_BOMB} weapon;
typedef struct {
int first_enemy[LEVELS],
last_enemy[LEVELS];
} enemy_idx;
typedef struct {
char name[36];
long hitpoints,
strength,
defense;
weapon arm;
} enemy;
void
main(void)
{
FILE *justfile;
enemy erec;
enemy_idx eidx;
char key;
int num=0;
int lvl=0;
int cnt;
char nnm[36];
// system("ren nyenm.dat nyenmb.dat");
// system("ren nyenm.idx nyenmb.idx");
system("del nyenm.dat");
system("del nyenm.idx");
eidx.first_enemy[0]=0;
do {
// printf("\nA-Add N-Next level Q-Quit>");
scanf("%c",&key);
dump();
if (key=='A' || key=='a') {
// printf("Name of the sucker:");
cnt=0;
do {
scanf("%c",&key);
erec.name[cnt]=key;
cnt++;
} while (key!='\n' && key!='\r' && cnt<36);
erec.name[cnt-1]=0;
if (key!='\n' && key!='\r') dump();
// printf("Hitpoints:");
scanf("%ld",&erec.hitpoints);
dump();
// printf("Strength:");
scanf("%ld",&erec.strength);
dump();
// printf("Defense:");
scanf("%ld",&erec.defense);
dump();
// printf("Arm:");
scanf("%d",&erec.arm);
dump();
justfile=fopen("NYENM.DAT","a+b");
// printf("Atpos: %d\n\n",ftell(justfile)/sizeof(enemy));
fwrite(&erec,sizeof(enemy),1,justfile);
fclose(justfile);
num++;
} else if (key=='N' || key=='n') {
eidx.last_enemy[lvl]=num;
lvl++;
eidx.first_enemy[lvl]=num;
}
} while (key!='q' && key!='Q');
eidx.last_enemy[lvl]=(--num);
justfile=fopen("NYENM.IDX","wb");
fwrite(&eidx,sizeof(enemy_idx),1,justfile);
fclose(justfile);
printf("\nDone!");
}
void
dump(void)
{
char key;
do {
scanf("%c",&key);
} while (key!='\n');
}